<template>
	<view class="page">
		<template >
			<view class="body">
				<view class="start-btn-area">
					 
					<view class="inp-bar">
						<view class="label">设备编号</view>	
						<input type="text" placeholder="请输入" />
					</view>	
					<view class="btn-wrap">
						<view class="submit-btn">提交</view>
					</view>	
					<template > 
						<view class="btn" > 
							<image src="@/static/images/fk_scan_start.png" mode="widthFix"></image>
						</view>
						<!-- <view class="name"><text>投药旗扫码作业</text></view> -->
					</template>
				</view>
			</view>	 			
 
			<c-nav switchTab="1"></c-nav> 
		</template>
	</view>
</template>

<script> 
	 
	export default {
		name: 'name',
		data() {
			return { 
				isLogin: false, 
				userInfo: uni.getStorageSync('userInfo'),
				loginStateUpdate: false,
				isCertificage:'',   // 1 获得资格，去填写信息  // -2 不满足资格，需学习实操   // 2 已获取证书
				app_name: getApp().globalData.app_name,
				type:1,
				isActive:false,
				temperature_float:''
			} 
		},
		async onLoad() {			
			 
		},
		async onShow() { 			
			 
			
		},
		onHide() {
			Hide();
		},
		onUnload() {
			Hide();
		},
		methods: { 
			 	
			  
			
			// 检测领证条件
			checkCertificate:async function(){
				let h_res=await this.$api.yfk_api.checkCertificate();    // 检测是否满足领取条件，1满足领取条件  
				if(h_res.data.ret==1){
					let res=await this.$api.yfk_api.certificateInfo();  
					if(res.data.ret==-1 || (res.data.ret==1&&(res.data.data.isaudit==0||res.data.data.isaudit==2))){    
						// -1 无证书  1 有证书 审核中 0 审核失败2 弹窗
						let system = await getSystemInfo(); //  获取系统信息 
						this.isActive=false;
						getCardTips({
							system:system
						}); 
					}else{
						this.isActive=true;
						this.getyfkgofk();
					}		
				}else{ 
					// 审核中 0 审核失败2 弹窗
					let system = await getSystemInfo(); //  获取系统信息
					this.isActive=false;
					getCardTips({
						system:system
					}); 
				}
			},
			 
			 
			changeType:function(type){
				this.type=type;
			},
			
			goWork:function(){ 
				uni.navigateTo({
					url:'/package_active/form/form'
				})
			},
			
			// 支付宝扫码
			scanCode:async function(){
				if(!this.isActive){
					let system = await getSystemInfo(); //  获取系统信息
					setTimeout(()=>{
						getCardTips({
							system:system
						}); 
					},500) 
					return
				}
				
				// #ifdef APP-PLUS 
				var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
				mpaasScanModule.mpaasScan({
						// 扫码识别类型，参数可多选，qrCode、barCode，不设置，默认识别所有
						'scanType': ['qrCode', 'barCode'],
						// 是否隐藏相册，默认false不隐藏
						'hideAlbum': true
					},
					async (res) => { 
						if(res.resp_message=="success"){							
							let query=res.resp_result.split('?')[1];					
							let query_data=queryToJSON(query); 
							uni.showLoading();
							let result=await this.$api.pro_api.qmfkScanResult({
								devnumber:query_data.devnumber,
								uuid:query_data.uuid 
							})    
							if(result.data.ret==1){
								uni.hideLoading();
								uni.navigateTo({
									url:`/package_active/form/form?type=scan&pro_id=${result.data.data.pro_id}&devnumber=${query_data.devnumber}&uuid=${query_data.uuid}`
								})
							}else if(result.data.ret==0){
								uni.hideLoading();
								uni.navigateTo({
									url:`/package_active/dataDetail/dataDetail?id=${result.data.data}`
								})
							}else{
								uni.hideLoading();
								uni.showToast({
									icon: "none",
									title: result.data.message, 									 
								})
							} 
						} 
						
						// uni.showModal({
						// 	title: "弹窗标题",
						// 	// 返回值中，resp_code 表示返回结果值，10：用户取消，11：其他错误，1000：成功
						// 	// 返回值中，resp_message 表示返回结果信息
						// 	// 返回值中，resp_result 表示扫码结果，只有成功才会有返回
						// 	content: JSON.stringify(ret),
						// 	showCancel: false,
						// 	confirmText: "确定"
						// })
					})
				// #endif
			}, 
			 
		},
		components: {

		},

		computed: {

		},
		watch: {

		}

	}
</script>

<style lang="less" scoped> 
	.page,.body{
		height: 80%;
		background: #fff;
	}
	.category-list{
		background: #fff;
		margin-bottom: 20rpx;
		padding: 20rpx 0 0;
		.item{
			.icon{
				width: 30%!important;
			}
		}
	}
	.name {
		text-align: center;

		text {
			padding-top: 10rpx;
			border-top: 2rpx dashed #999;
			font-size: 28rpx;
			color: #999;
		}
	}
	
	.tab-bar{
		position: absolute;
		left:0;
		top:0;
		width: 100%;
	}
	.tab{ 
		width: 80%;		
		margin: 0 auto;
		display: flex;
		justify-content: center;
		align-items: center;
		// border:1rpx solid #f00;
		border-radius: 10rpx;
		font-size: 32rpx;
		.item{
			width: 50%; 
			height: 82rpx;
			line-height: 82rpx;
			text-align: center;
			color:#666;
			background: #fff;
			border-radius: 10rpx;
		}
		.active{
			height: 82rpx;
			line-height: 82rpx;
			background: #f00;
			color:#fff;
			border-radius: 8rpx;
		}
	}
	
	.start-btn-area{	
		padding-top: 150rpx;
		height: 90%;
		background: #f5f5f5;
		.inp-bar{
			display: flex;
			align-items: center;
			width: 80%;
			margin: 0 auto 40rpx;
			.label{
				margin-right: 20rpx;
				flex-shrink: 0;
				font-size: 32rpx;
				color: #999;
			}
			input{
				flex-grow: 2;
				padding: 20rpx 10rpx;
				border: 2rpx solid rgba(218, 221, 228, 1);
				border-radius: 10rpx;
				font-size: 32rpx;
				background: #fff;
			}
		}
		.btn-wrap{
			width: 80%;
			margin: 0 auto;
			display: flex;
			justify-content: flex-end;
			.submit-btn{
				padding: 20rpx 40rpx;
				border: 2rpx solid rgba(218, 221, 228, 1);
				border-radius: 10rpx;
				font-size: 28rpx;
				background: #fff;
				color: #606266;
			}
		}
	}
	
	.get-code-popup {
		.phone-text {
			margin-bottom: 30rpx;
			color: #666;
		}
	
		.code-comfirm-btn {
			height: 70rpx;
			line-height: 70rpx;
			margin: 0 auto;
			background: linear-gradient(#e96b5c, #ce3c2f);
			border-radius: 8rpx;
			color: #fff;
			text-align: center;
			font-size: 30rpx;
		}
	}
	.code-bar {
		display: flex;
		height: 80rpx;
		border: 1rpx solid #eee;
		border-radius: 15rpx;
		margin-bottom: 40rpx;
	
		input {
			width: 90%;
			height: 80rpx;
			line-height: 80rpx;
			padding: 0 10rpx;
			font-size: 30rpx;
		}
	
		.get-code-btn {
			flex-shrink: 0;
			width: 35%;
			line-height: 80rpx;
			text-align: center;
			font-size: 30rpx;
			color: #09f;
		}
	}

	.btn {
		width: 60%;
		margin: 20% auto 0;  
		image {
			width: 100%;
		}
	}
	
	
</style>
